import * as types from '../actionTypes'

// 状态
const state = {
  username: 'wangxiaofei',
  password: '111111'
}

// 回写
const mutations = {
  [types.CHANGENAME] (state, newName) {
    state.username = newName
  }
}

// 衍生属性
const getters = {
	coolMan: state => state.username + " cool"
}

// 事件
const actions = {
	changeName ({ commit, state }, newName) {
		commit('CHANGENAME', newName)
	}
}

export default {
  state,
  mutations,
  getters,
  actions
}